package extration;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map.Entry;

public class ModeleMultinomial extends Modele{
	
	public ModeleMultinomial(Data d){
		data = d;
	}

	//Parametre binomial
	public void parametreMultimonial(){
		mapPos= new HashMap<Mot,Float>();
		mapNeg = new HashMap<Mot,Float>();
		mapNeu = new HashMap<Mot,Float>();
		mapIrr = new HashMap<Mot,Float>();
		Float nb = 0.0f;
		for(Mot mot : apprentissage){
			for(Entry<String,Integer>  entry: mot.getNbOccPolarite().entrySet()){
				String p = entry.getKey();
				int nbOcc = entry.getValue();
				int nbOccTotPolarite = data.getPolarite().get(p).getNbOccTotal();
				nb = (float) nbOcc/(float) nbOccTotPolarite;
				if(nb ==1){
					nb = 1-EPSILON;
				}
				else if(nb == 0){
					nb = EPSILON;
				}
				if(p.equals(Data.POSITIVE))
					this.mapPos.put(mot, nb);
				if(p.equals(Data.NEGATIVE))
					this.mapNeg.put(mot, nb);
				if(p.equals(Data.NEUTRAL))
					this.mapNeu.put(mot, nb);
				if(p.equals(Data.IRRELEVANT))
					this.mapIrr.put(mot, nb);
			}
		}
	}

}
